package com.reporting.yb.module.system.dal.mysql.reporting;

import com.reporting.yb.framework.common.pojo.PageResult;
import com.reporting.yb.framework.mybatis.core.mapper.BaseMapperX;
import com.reporting.yb.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.reporting.yb.module.system.controller.admin.reporting.vo.ReportingPageReqVO;
import com.reporting.yb.module.system.dal.dataobject.reporting.ReportingDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 投诉信息 Mapper
 *
 * @author 123
 */
@Mapper
public interface ReportingMapper extends BaseMapperX<ReportingDO> {

    default PageResult<ReportingDO> selectPage(ReportingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReportingDO>()
                .eqIfPresent(ReportingDO::getIsAnonymity, reqVO.getIsAnonymity())
                .eqIfPresent(ReportingDO::getUserId, reqVO.getUserId())
                .likeIfPresent(ReportingDO::getReportName, reqVO.getReportName())
                .eqIfPresent(ReportingDO::getReportIdentityCard, reqVO.getReportIdentityCard())
                .eqIfPresent(ReportingDO::getReportAddress, reqVO.getReportAddress())
                .eqIfPresent(ReportingDO::getReportTel, reqVO.getReportTel())
                .likeIfPresent(ReportingDO::getBeReportedName, reqVO.getBeReportedName())
                .eqIfPresent(ReportingDO::getBeReportedUnit, reqVO.getBeReportedUnit())
                .eqIfPresent(ReportingDO::getBeReportedOffice, reqVO.getBeReportedOffice())
                .eqIfPresent(ReportingDO::getBeReportedLevel, reqVO.getBeReportedLevel())
                .eqIfPresent(ReportingDO::getTitle, reqVO.getTitle())
                .eqIfPresent(ReportingDO::getCategory, reqVO.getCategory())
                .eqIfPresent(ReportingDO::getCategoryDetail, reqVO.getCategoryDetail())
                .eqIfPresent(ReportingDO::getContent, reqVO.getContent())
                .eqIfPresent(ReportingDO::getFileId, reqVO.getFileId())
                .eqIfPresent(ReportingDO::getAcceptSituation, reqVO.getAcceptSituation())
                .eqIfPresent(ReportingDO::getClueSituation, reqVO.getClueSituation())
                .betweenIfPresent(ReportingDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ReportingDO::getIllustrate, reqVO.getIllustrate())
                .eqIfPresent(ReportingDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ReportingDO::getCreator, reqVO.getCreator())
                .eqIfPresent(ReportingDO::getIsSee, reqVO.getIsSee())
                .eqIfPresent(ReportingDO::getState, reqVO.getState())
                .eqIfPresent(ReportingDO::getStateOne, reqVO.getStateOne())
                .eqIfPresent(ReportingDO::getStateTwo, reqVO.getStateTwo())
                .eqIfPresent(ReportingDO::getStaeThree, reqVO.getStaeThree())
                .eqIfPresent(ReportingDO::getStateFour, reqVO.getStateFour())
                .eqIfPresent(ReportingDO::getStateFive, reqVO.getStateFive())
                .orderByDesc(ReportingDO::getCreateTime));
    }
    @Select("SELECT * FROM system_reporting " +
            "WHERE (accept_situation IS NULL OR accept_situation = '') " +
            "AND (clue_situation IS NULL OR clue_situation = '') " +
            "AND category = #{category} ")
    PageResult<ReportingDO> getListreporting(String category);

}